import json
import re

content="""
{
"assessment_metadata": {
"assessment_date": "2024-11-28",
"assessment_model": "人岗匹配度评估模型v2.0",
"industry_benchmark": "计算机信息技术服务业"
},
"overall_evaluation": {
"total_score": {
    "score": 6.5,
    "grade": "C级(合格)",
    "conclusion": "候选人具备一定的技术能力和项目经验，但在经验和教育背景方面与目标岗位的要求存在一定差距。建议进一步提升Java开发经验和Linux服务器管理能力。"
},
"dimension_scores": {
    "technical_match": 7.5,
    "experience_match": 5.5,
    "education_match": 6.0,
    "potential_match": 7.0
}
},
"competency_analysis": {
"technical_skills": {
    "score": 7.5,
    "strengths": [
        "全面的全栈开发能力，尤其在Spring Boot和Vue3框架上有深入掌握",
        "熟练使用Git进行版本控制，具备良好的代码管理能力"
    ],
    "weaknesses": [
        "Java开发经验不足3年，且缺乏对Spring Cloud等复杂微服务架构的经验",
        "Linux环境下的服务器部署与维护经验较少"
    ],
    "evidence": [
        "成功交付多个基于Flask+Vue3+MySQL的全栈项目",
        "参与了大模型面试官和鸟类时空数据挖掘平台等复杂项目"
    ],
    "gap_analysis": "候选人虽然具备较强的前后端开发能力，但在Java开发经验、Spring Cloud以及Linux服务器管理方面仍需进一步提升。"
},
"project_experience": {
    "score": 6.5,
    "key_projects": [
        {
            "project_name": "大模型面试官",
            "relevance": 7.0,
            "highlight": "负责项目的整体架构设计与实现，展示了较强的领导力和技术深度"
        },
        {
            "project_name": "鸟类时空数据挖掘平台",
            "relevance": 6.5,
            "highlight": "构建了高效的数据清洗管道和RESTful接口，提升了系统的性能和可维护性"
        }
    ],
    "experience_quality": "候选人的项目经验丰富，涵盖了从需求分析到系统上线的全过程，但项目规模和技术复杂度相对较小，尤其是缺少大型企业级项目的经历。"
},
"soft_skills": {
    "score": 7.0,
    "leadership": 7.5,
    "communication": 7.0,
    "teamwork": 6.5,
    "evidence": [
        "作为无人机协会项目部部长，协调各部门并组织社团招聘",
        "在多个项目中担任负责人或核心开发人员，展示了较强的团队协作和沟通能力"
    ]
}
},
"salary_analysis": {
"market_position": {
    "current_range": "6-11K",
    "market_range": "15-25K",
    "position_percentage": "位于市场水平的30%-50%之间"
},
"expectation_analysis": {
    "expectation_reasonability": 5.0,
    "gap_with_budget": "期望薪资低于岗位预算，但考虑到经验和技能差距，存在一定的不合理性",
    "suggestion": "建议将基本工资设定在8-10K，并根据表现逐步调整"
},
"compensation_structure": {
    "base_salary": "8-10K",
    "bonus": "绩效奖金",
    "other_benefits": ["五险一金", "年度体检"]
}
},
"development_suggestions": {
"short_term": [
    {
        "aspect": "提升Java开发经验",
        "priority": "高",
        "specific_actions": [
            "参与更多Java相关项目，尤其是企业级应用的开发",
            "学习Spring Cloud等微服务框架，增强分布式系统开发能力"
        ],
        "expected_outcome": "在未来6个月内达到3年以上Java开发经验的要求"
    },
    {
        "aspect": "加强Linux服务器管理",
        "priority": "中",
        "specific_actions": [
            "参加Linux系统管理培训课程",
            "实践服务器部署与维护操作"
        ],
        "expected_outcome": "能够在实际工作中独立完成服务器部署与维护任务"
    }
],
"long_term": {
    "career_path": [
        "Java开发工程师",
        "高级Java开发工程师",
        "技术项目经理"
    ],
    "key_milestones": [
        "获得Oracle Certified Professional (OCP) 认证",
        "主导一个大型企业级Java项目的开发"
    ],
    "required_skills": [
        "深入理解Spring Cloud和微服务架构",
        "掌握Docker和Kubernetes容器化技术"
    ]
},
"training_recommendations": [
    {
        "course": "Java EE企业级应用开发实战",
        "priority": "高",
        "benefit": "快速提升Java开发技能，掌握企业级应用开发流程"
    },
    {
        "course": "Linux系统管理与服务器运维",
        "priority": "中",
        "benefit": "提高服务器管理和运维能力，适应更复杂的工作环境"
    }
]
}
}
"""
# 使用正则表达式提取有效的JSON内容
json_pattern = r'({[\s\S]*})'
match = re.search(json_pattern, content)

if match:
    # 提取匹配到的JSON字符串
    json_str = match.group(1)

    # 清理JSON字符串
    json_str = json_str.strip()
    json_str = re.sub(r'[\n\t\r]+', '', json_str)
    json_str = re.sub(r'\s+(?=[^"]*"(?:[^"]*"[^"]*")*[^"]*$)', ' ', json_str)

    # 解析JSON
    json_obj = json.loads(json_str)

    # 提取所需字段
    total_score = json_obj['overall_evaluation']['total_score']['score']
    technical_match = json_obj['overall_evaluation']['dimension_scores']['technical_match']
    experience_match = json_obj['overall_evaluation']['dimension_scores']['experience_match']
    education_match = json_obj['overall_evaluation']['dimension_scores']['education_match']
    potential_match = json_obj['overall_evaluation']['dimension_scores']['potential_match']
    print(total_score, technical_match, experience_match, education_match, potential_match)
